package com.ww.springboot.dd.controller;

import cn.hutool.json.JSONUtil;
import com.ww.springboot.dd.dto.SaleDTO;
import com.ww.springboot.dd.mapper.HiveMapper;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 描述：
 *
 * @author 🧑 ‍wanwei
 * @since 2023-03-01 14:30
 */
//@RestController
@RequestMapping("/hive")
@AllArgsConstructor
public class HiveController {

    private final HiveMapper hiveMapper;

    @GetMapping("find")
    public String find(String spu) {
        Map<String, String> map = hiveMapper.selectAll(spu);
        return JSONUtil.toJsonStr(map);
    }

    @GetMapping("find2")
    public String find2(String spu) {
        List<SaleDTO> saleDTOS = hiveMapper.selectAll2(spu);
        saleDTOS.forEach(map -> {


        });
        return JSONUtil.toJsonStr(saleDTOS);
    }
}
